# Importing Data
GAUTIMALA<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Rubber/Rubber.xlsx",sheet = "Sheet1", range = "c1:c325")

# Checking the Imported Data
View(GAUTIMALA)
# Creating Time Series Data
GAUTIMALA_ts <- ts(GAUTIMALA, start=c(2004,1), end=c(2017,12), frequency=12)
# Viewing and Checking the Created Time Series Data
GAUTIMALA_ts
sum(is.na(GAUTIMALA_ts))
library(forecast)
GAUTIMALA_ts <- tsclean(GAUTIMALA_ts)
GAUTIMALA_ts

# Identification: Plotting the Time Series Data
plot(GAUTIMALA_ts)

# Estimating the appropriate model
GAUTIMALA_ts_model <- auto.arima(GAUTIMALA_ts)
GAUTIMALA_ts_model

# Forecasting
options(max.print=1000000)
GAUTIMALA_ts_forecast <- forecast (GAUTIMALA_ts_model, level=c(95), h=276)
plot(GAUTIMALA_ts_forecast)
GAUTIMALA_ts_forecast             

# Exporting
write.table(GAUTIMALA_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Rubber/GAUTIMALA_TSA.csv", sep=",")


